#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2022/5/6 15:27
# @Author  : peng bo
# @Site    : 
# @File    : start.py.py
# @Software: PyCharm

from app import create_app
from flask_cors import CORS

# 创建flask的app对象

app = create_app()

# 第二种方式解决跨域
CORS(app)

# 创建全站拦截器，每个请求之后根据请求方法统一设置返回头
# @app.after_request
# def process_response(response):
#     # 第一种方式解决跨域
#     allow_cors = ['OPTIONS', 'PUT', 'DELETE', 'GET', 'POST']
#     if request.method in allow_cors:
#         response.headers["Access-Control-Allow-Origin"] = '*'
#         response.headers["Access-Control-Allow-Credentials"] = 'true'
#         response.headers['Access-Control-Allow-Methods'] = 'OPTIONS,GET,POST,PUT,DELETE'
#         response.headers['Access-Control-Allow-Headers'] = 'x-requested-with,content-type,Token,Authorization'
#         response.headers['Access-Control-Expose-Headers'] = 'VerifyCodeID,ext'
#     return response


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=True, threaded=True)